<template>
	<view>
		<uni-forms :modelValue="Memorandum">
			<uni-forms-item label="ID" v-if="false" >
				<uni-easyinput v-model="Memorandum.bId" />
			</uni-forms-item>
			<uni-forms-item label="用户ID" v-if="false" >
				<uni-easyinput v-model="Memorandum.userId"/>
			</uni-forms-item>
			<uni-forms-item label="标题">
				<uni-easyinput  v-model="Memorandum.title" />
			</uni-forms-item>
			<!-- <uni-forms-item label="日期时间">
				<uni-datetime-picker type="datetime" return-type="timestamp" v-model="Memorandum.date"/>
			</uni-forms-item> -->
			<uni-forms-item label="内容">
				<uni-easyinput type="textarea" v-model="Memorandum.content" />
			</uni-forms-item>		
		</uni-forms>
		<button type="primary" size="mini" @click="submit()">保存</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				Memorandum: {
					bId:"",
					userId:"",
					title:"",
					date:"",
					content:"",
					
				},
				token:""
			}
		},
		onLoad() {
			uni.getStorage({
				key : 'user',
				success: res=>{
					console.log(res.data.userId);
					this.Memorandum.userId=res.data.userId
				}
			});
			uni.getStorage({
				key:'token',
				success: res=>{
					// console.log(res.data);
					this.token=res.data
				}
			})
		},
		methods: {
			submit(){
				uni.request({
					url:'http://8.130.170.106:9999/memorandum/insert',
					data:{
						userId: this.Memorandum.userId,
						title: this.Memorandum.title,
						content: this.Memorandum.content
					},
					header:{
						token:this.token
					},
					success: (res) => {
						uni.switchTab({
							url: '/pages/main/tabbar/tabbar-4/tabbar-4',
							success: () => {
							  console.log("跳转成功");
							},
							fail: (err) => {
							  console.log("跳转失败", err);
							}
						});
					}
				})
			}
		}
	}
</script>

<style>
	.title {
	  font-weight: bold;
	  font-size: 16px;
	}
	.button {
			display: flex;
			align-items: center;
			height: 35px;
			margin-left: 10px;
		}
</style>
